# Makefile for libdgnsc
# Copyright (C) 2009-2010 drangon <drangon.zhou@gmail.com>
# 2009-05
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

DSO_TARGET = libdgnsc.so

SRCS += $(wildcard *.c)

OBJS = $(foreach src, $(SRCS), $(basename $(src)).o)
DEPS = $(foreach src, $(SRCS), $(basename $(src)).zzdep)

AR = ar
GCC = gcc
CFLAGS += -g -Wall -pipe -I..

ifeq ($(strip $(OS)),Windows_NT)
IMPLIB=$(DSO_TARGET:.so=.dll).a
LDFLAGS += -Wl,--out-implib=$(IMPLIB) -lwinmm -lws2_32
else
CFLAGS += -DPIC -fPIC
LDFLAGS += -ldl -lpthread -lrt -lm
endif

.PHONY : all clean 

all : $(DSO_TARGET)
	cp -f dgnsc_all.h $(DSO_TARGET) $(IMPLIB) ../

# $(CXX) $(CFLAGS) -x c++-header libtestfc.h

clean :
	rm -f $(DSO_TARGET) $(IMPLIB) *.o *.zzdep

# $(LIB_TARGET) : $(OBJS)
# 	$(AR) crsv $(LIB_TARGET) $(OBJS)

$(DSO_TARGET) : $(OBJS)
	$(GCC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS)

.SUFFIXES : .c

.c.o :
	$(GCC) $(CFLAGS) -MMD -MF $*.zzdep -c -o $@ $<

-include $(DEPS)

